package xyz.xtt.asset.client.response;

import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Builder.Default;
import lombok.Data;
import lombok.NoArgsConstructor;
import xyz.xtt.asset.client.request.MintDataVo;

/**
 * @author huqibo
 * @date 2025/03/04
 */
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
public class MintResponse {
	@NotBlank(message = "description不能为空")
	private String description;
	@Schema(description = "扩展信息")
	private String externalUrl;
	@NotBlank(message = "展示图不能为空")
	private String image;
	@NotBlank(message = "资产名称不能为空")
	private String name;
	@Schema(description = "上链字段信息")
	@Valid
	@NotNull(message = "上链属性不能为空")
	@NotEmpty(message = "上链属性不能为空")
	private List<MintDataVo> attributes;
	@NotBlank(message = "作者appUid")
	private String authorId;
	@Schema(description = "合约类型 721/1155")
	private String referProtocol;
	@Schema(description = "资产类型编码")
	private String assetType;
	@Schema(description = "业务方id")
	private String bizId;
	@Schema(description = "链框架id")
	private Integer chainId;
	@Schema(description = "资产数量")
	private Integer amount;
	@Schema(description = "资产价格")
	private BigDecimal price;
	@Schema(description = "付款方式 1 通宝 2通钻 3人民币")
	private Integer unit;
	@Schema(description = "业务类型")
	private String bizType;
	@Schema(description = "出售开始时间")
	private Long sellStartDatetime;
	@Schema(description = "出售结束时间")
	private Long sellEndDatetime;
	@Schema(description = "是否上链")
	@Default
	/**
	 * 是否上链
	 */
	private Boolean upChain = Boolean.TRUE;
	@Schema(description = "出售结束时间")
	private Long assetId;
	@Schema(description = "交易订单id")
	private Long transactionOrderId;
	@Schema(description = "资产编号")
	@Default
	private Long seqNo = 0L;
	
	@Schema(description = "是否可售卖")
	@Default
	private Integer sellable = 0;
	@Schema(description = "是否可赠送")
	@Default
	private Integer giftable = 0;
	@Schema(description = "是否可参与排行榜")
	@Default
	private Integer rankable = 1;

	public Boolean checkAmount() {
		return Objects.nonNull(amount) && amount.intValue() > 0;
	}

	public Boolean checkAmountWithOne() {
		return Objects.nonNull(amount) && amount.intValue() == 1;
	}
}
